﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;

public partial class Crm_webconfig : BaseCrm
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
          DataTable dt= BLL.DataBaseHelper.instance.GetModel("webconfig", "", "");
            if(dt.Rows.Count>0)
            {            
                txtSiteName.Text =dt.Rows[0]["sitename"].ToString();
                txtKeyWords.Text = dt.Rows[0]["keywords"].ToString();
                txtBrief.Text = dt.Rows[0]["brief"].ToString();
                txtTitle.Text = dt.Rows[0]["title"].ToString();
                chkIsLock.Checked = dt.Rows[0]["islock"].ToString() == "False" ? false : true;
                chklShowtype.SelectedValue = dt.Rows[0]["showtype"].ToString();
                txtClosePage.Text = dt.Rows[0]["closepage"].ToString();
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {       
        Hashtable hs = new Hashtable();
        hs.Add("sitename", StringHelper.ReplaceBadChar(txtSiteName.Text));
        hs.Add("title", StringHelper.ReplaceBadChar(txtTitle.Text));
        hs.Add("keywords", StringHelper.ReplaceBadChar(txtKeyWords.Text));
        hs.Add("islock", chkIsLock.Checked);
        hs.Add("brief", txtBrief.Text);
        hs.Add("showtype", chklShowtype.SelectedValue);
        hs.Add("closepage", txtClosePage.Text.Trim());
        try
        {
            BLL.DataBaseHelper.instance.Update(hs,"webconfig","");
            Cache.Remove("webconfig_model");
            lblResult.Text = "操作成功!";
        }
        catch(Exception ex)
        {
            throw ex;
        }
    }
}
